<template>
	<view class="waterfall-item" @tap="onTap" v-if="params.url">
		<image :src="params.url" mode="widthFix" style="border-radius: 5px 5px 0 0;" @load="emitHeight" @error="emitHeight"></image>
		<view class="content">
			<view class="title">{{params.title}}</view>
			<view class="note_detail">
				<image :src="params.authorUrl" class="authorUrl"></image>
				<text>{{params.authorN}}</text>
			</view>
			
		</view>
			<image src="/static/images/play.png"  style="width: 30px;height: 30px;position: absolute;top: 10px;right: 10px;" v-if="params.mv"></image>
	</view>
</template>

<script>
	export default {
		name:"helang-waterfall",
		props:{
			params:{
				type: Object,
				default(){
					return {}
				}
			},
			tag:{
				type:String | Number,
				default:''
			},
			index:{
				type:Number,
				default:-1
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e){
				const query = uni.createSelectorQuery().in(this);
				query.select('.waterfall-item').boundingClientRect(data => {
					let height = Math.floor(data.height);
					// console.log(height)
					this.$emit("height",height,this.$props.tag);
				}).exec();
			},
			onTap(){
				this.$emit("click",this.$props.index,this.$props.tag);
			}
		}
	}
</script>

<style lang="scss" scoped>
.waterfall-item{
	// padding: 16rpx;
	background-color: #fff;
	border-radius: 5px;
	font-size: 28rpx;
	color: #666;
	margin-bottom: 20rpx;
	position: relative;
	image{
		display: block;
		width: 100%;
		// 默认设置一个图片的大约值
		height: 350rpx;
	}
	
	.content{
		padding: 16rpx;
		// margin-top: 16rpx;
		.title{
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			overflow: hidden;
		}
		.note_detail{
			font-size: 12px;
			display: flex;
			align-items: center;
			margin-top: 10px;
			.authorUrl{
				width: 20px;
				height: 20px;
				border-radius: 50%;
				margin-right: 10px;
			}
		}
		
	}
}
</style>
